package chwgigs.swing.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class EX01_SungJukService implements EX01_ISungJukService {
    private static EX01_SungJukDAO sdao =new EX01_SungJukDAO();
    @Override
	public int tot(int kor, int eng, int mat) {
		
		return kor + eng + mat;
	}
	@Override
	public double avg(int tot) {
		
		return 
				Math.round(((tot)/ (double)3)*100)/100.0;
	}
	@Override
	public String grd( double avg) {
            
		switch ((int)avg /10){
	   case 10: case 9:  return "A";
	   case 8 : return "B  "; 
	   case 7 : return "c  "; 
	   case 6 : return "d  "; 
	   default : return" 때려쳐라 "; 
	   
		}
	
	}

    
    
    @Override
	public void createSungJuk() {
	
		
		EX01_SungJukVO sj = new EX01_SungJukVO();
		
		System.out.println("내점수는요"  );
		Scanner sc= new Scanner(System.in);
		
		System.out.println("국어점수는");
		sj.setKor(sc.nextInt());
		System.out.println("수학점수는");
		sj.setMat(sc.nextInt());
		System.out.println("영어점수는");
	    sj.setEng(sc.nextInt());
	  
	 //sj.setTot(this.tot(sj.getKor(),sj.getEng(),sj.getMat()));
	 sj.setAvg(this.avg(sj.getTot()));
	 sj.setGrd(this.grd(sj.getAvg()));    
	    
	    
	    
	  
	  if (sdao.insertSungJuk(sj))
		 System.out.println("니가가라 하와이");
	 else
		 System.out.println("너나가라");
	
	}
	@Override
	public List<EX01_SungJukVO> ReadSungJuk() {
	  Connection conn = null;
	  PreparedStatement pstmt = null;
	  ResultSet rs=null;
	  List<EX01_SungJukVO>result = new ArrayList<>();
		return null;
	}
	
	
	
	
	
}//